#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/12/30 21:17|21:17
# @Author  : yangdingyi
# @File    : 同构字符串
# @Software: PyCharm


class Solution:
    def isIsomorphic(self, s: str, t: str) -> bool:
        # map_s = {}
        # list_s = []
        # count_s = 0
        # for c in s:
        #     if map_s.get(c, None):
        #         list_s.append(map_s[c])
        #     else:
        #         count_s += 1
        #         map_s[c] = count_s
        #         list_s.append(count_s)
        # ss = ','.join(map(str, list_s))
        #
        # map_t = {}
        # list_t = []
        # count_t = 0
        # for c in t:
        #     if map_t.get(c, None):
        #         list_t.append(map_t[c])
        #     else:
        #         count_t += 1
        #         map_t[c] = count_t
        #         list_t.append(count_t)
        # tt = ','.join(map(str, list_t))
        #
        # return ss == tt
        hashmap = {}
        ismap = {}
        for i in range(len(s)):
            if s[i] in hashmap:
                if hashmap[s[i]] != t[i]:
                    return False
            else:
                if t[i] in ismap:
                    return False
                hashmap[s[i]] = t[i]
                ismap[t[i]] = True
        return True



solve = Solution()
# s = "egg"
# s = "foo"
s = "paper"

# t = "add"
# t = "bar"
t = "title"

print(s, t)
print(solve.isIsomorphic(s, t))

"""
hashmap
ismap
"""